package com.jason.session;

import com.jason.config.Configuration;
import com.jason.config.XMLConfigBuilder;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    private Configuration configuration;

    public SqlSessionFactoryBuilder() {
        this.configuration = new Configuration();
    }

    public SqlSessionFactory builder(InputStream inputstream) throws DocumentException, PropertyVetoException, ClassNotFoundException {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(configuration);
        Configuration configuration = xmlConfigBuilder.parse(inputstream);
        return new DefaultSqlSessionFactory(configuration);
    }

}
